/*
package com.controller;

import com.pojo.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;
@Controller("userControllerImpl")
@RequestMapping("/user")
public class ContractControllerImpl {
    @Autowired
    private UserService userService;

    @RequestMapping("/add")
    public String add(@Valid User user, Errors errors) {
        if(errors.hasErrors()){
            for (ObjectError e:errors.getAllErrors()) {
                System.out.println(e.getDefaultMessage());
            }
            return "redirect:/register.jsp";
        }
        if (userService.add(user)) return "redirect:/login1.jsp";
        return "redirect:/register.jsp";
    }

    @RequestMapping("/check")
    public String check(@Valid @ModelAttribute("user") User user, Errors errors) {
        if(errors.hasErrors()){
            for (ObjectError e:errors.getAllErrors()) {
                System.out.println(e.getDefaultMessage());
            }
            return "redirect:/login1.jsp";
        }
        System.out.println(1111);
        int back = userService.check(user);
        System.out.println(222);
        if (back == 1) return "redirect:/register.jsp";
        else if (back == 2) return "redirect:/login1.jsp";
        return "success";
}
*/
